import numpy as np
import matplotlib.pyplot as plt
from scipy.signal import find_peaks
from MUSIC_tools import *

# 参数设置
num_signals = 2
num_sensors = 4
sensor_distance = 0.5  # 传感器间距
wavelength = 1  # 波长
SNR_dB = 20  # 信噪比
theta_resolution = 1  # 角度分辨率
num_samples = 1000  # 采样点数

# 生成模拟水听器阵列信号
array_signal = generate_signal(num_signals, num_sensors, sensor_distance, wavelength, SNR_dB, num_samples)

# 运行MUSIC算法
estimated_theta = music_algorithm(array_signal, sensor_distance, wavelength, theta_resolution, num_signals)

# 绘制角度谱结果
draw_spectrum_result(spectrum, estimated_theta)


